home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5516 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: sn.no!usenet
  2. From: jan-henrik.haukeland@fou.telenor.no (jan-henrik haukeland)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to tell if a file exists in C
  5. Date: 07 Feb 1996 23:54:58 +0100
  6. Organization: LH*281263
  7. Message-ID: <m2buna4ugt.fsf@hawk.no>
  8. References: <4eqkj6$ipo@charm.magnus.acs.ohio-state.edu>
  9.     <m2pwbuvfb9.fsf@hawk.no> <823627565snz@genesis.demon.co.uk>
  10. NNTP-Posting-Host: nm2-ppp12.oslo.net
  11. In-reply-to: Lawrence Kirby's message of Tue, 06 Feb 96 17:26:05 GMT
  12. X-Newsreader: Gnus v5.0.12
  13.  
  14. Lawrence Kirby writes:
  15.  
  16.  : jan-henrik.haukeland@fou.telenor.no "jan-henrik haukeland" writes:
  17.  : 
  18.  : >Use the stat function, e.g.:
  19.  : >
  20.  : >int fexist(char * filename)
  21.  
  22. <snip>
  23.  
  24.  : This function returns 3 distinct values. As such it does not return a
  25.  : voolean-like quantity. Therefore it is highly misleading to label two of
  26.  : those return values as TRUE and FALSE - you should find some more
  27.  : appropriate names.
  28.  
  29. Should I ? Lets see, either the file exist or it don't - Yes. Normal usage
  30. of this function would be, something like:
  31.  
  32.     if ( ! fexist(filename)) {
  33.       /* Do stuff */
  34.         }
  35.  
  36. See, either it exist or it don't - and thats Boolean. But as a special
  37. "fyzzy logic" service, it will distinguish between TRUE, because even if it
  38. is TRUE that it exist, it's maybe not so true as You would like it to be,
  39. because it's NOT_A_REGULAR_FILE (i.e. a dir. a /dev ..). It is then
  40. possible to test for this. Beside did I say it was a boolean function, I
  41. think not. 
  42.  
  43.  : -----------------------------------------
  44.  : Lawrence Kirby | fred@genesis.demon.co.uk
  45.  : Wilts, England | 70734.126@compuserve.com
  46.  : -----------------------------------------
  47.  
  48.  
  49. jhh
  50.